; The name of the installer
Name "PyTDMaker"

; The file to write
OutFile "pytdmaker-setup.exe"

; The default installation directory
InstallDir $PROGRAMFILES\PyTDMaker

; Registry key to check for directory (so if you install again, it will 
; overwrite the old one automatically)
InstallDirRegKey HKLM "Software\PyTDMaker" "Install_Dir"

; Request application privileges for Windows Vista
RequestExecutionLevel admin

;--------------------------------

; Pages

PageEx license
    LicenseText "GNU General Public License 3.0"
    LicenseData "COPYING"
    LicenseForceSelection checkbox
PageExEnd

Page components
Page directory
Page instfiles

UninstPage uninstConfirm
UninstPage instfiles

;--------------------------------

; The stuff to install
Section "PyTDMaker (required)"
  SectionIn RO
  
  RMDir /r "$INSTDIR"
  CreateDirectory $INSTDIR
  
  ; Set output path to the installation directory.
  SetOutPath $INSTDIR
  
  ; Put file there
  File "pytdmaker.py"
  File "COPYING"
  
  SetOutPath $INSTDIR\win32
  File "win32\*"
  SetOutPath $INSTDIR\win64
  File "win64\*"
  
  ; Write the installation path into the registry
  WriteRegStr HKLM SOFTWARE\NSIS_PyTDMaker "Install_Dir" "$INSTDIR"
  
  ; Write the uninstall keys for Windows
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PyTDMaker" "DisplayName" "PyTDMaker"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PyTDMaker" "UninstallString" '"$INSTDIR\uninstall.exe"'
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PyTDMaker" "NoModify" 1
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PyTDMaker" "NoRepair" 1
  WriteUninstaller "uninstall.exe"
  
SectionEnd

; Optional section (can be disabled by the user)
Section "Start Menu Shortcuts"

  CreateDirectory "$SMPROGRAMS\PyTDMaker"
  CreateShortCut "$SMPROGRAMS\PyTDMaker\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  CreateShortCut "$SMPROGRAMS\PyTDMaker\PyTDMaker.lnk" "$INSTDIR\pytdmaker.py" "" "$INSTDIR\pytdmaker.py" 0
  
SectionEnd

; Optional section (can be disabled by the user)
Section "Desktop Shortcut"

  CreateShortCut "$DESKTOP\PyTDMaker.lnk" "$INSTDIR\pytdmaker.py" "" "$INSTDIR\pytdmaker.py" 0
  
SectionEnd

;--------------------------------

; Uninstaller

Section "Uninstall"
  
  ; Remove registry keys
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PyTDMaker"
  DeleteRegKey HKLM SOFTWARE\NSIS_PyTDMaker

  ; Remove shortcuts, if any
  Delete "$DESKTOP\PyTDMaker.lnk"

  ; Remove directories used
  RMDir /r "$SMPROGRAMS\PyTDMaker"
  RMDir /r "$INSTDIR"

SectionEnd
